package TAM;

import java.io.IOException;

public abstract class TopicModel {

	public void run(int iters, String filename) throws Exception {
		if (preprocessDocs(filename)) {
			filename = "Doc";
			//return;
		}

		readDocs(filename);
		initialize();

		System.out.println("Sampling...");

		for (int iter = 1; iter <= iters; iter++) {
			System.out.println("Iteration " + iter);
			doSampling();
		}

		// write variable assignments

		writeOutput(filename);

		System.out.println("...done.");
	}

	public abstract boolean preprocessDocs(String filepath) throws IOException;

	public abstract void initialize();

	public abstract void doSampling();

	public abstract void readDocs(String filename) throws Exception;

	public abstract void writeOutput(String filename) throws Exception;
}
